#!/usr/bin/perl -w

##HACKABOT_HELP##
# Everything needs a slogan!
# !slogan something
##HACKABOT_HELP##

use strict;
use LWP::Simple;
use URI::Escape;
use HTML::Entities;
use Hackabot::Client;

my $hbc = Hackabot::Client->new;
my $msg = $hbc->readline;
my $nick = $hbc->sent_by;

$msg =~ s/\s*$//;
$msg = uri_escape($msg);
my $page = get("http://www.sloganizer.net/en/outbound.php?slogan=$msg");
$page =~ /<a[^>]+>(.*)<\/a>/;
my $slogan = $1;

# decode twice because both uri_escape and sloganizer encoded things
$slogan = decode_entities($slogan);
$slogan = decode_entities($slogan);

print "send $nick: $slogan";
